<?php
/*
	转换
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
cfc('core')->checklogin();
$setting['percent']=round($this->setting['percent'],2);
if($_RQ['op']=='get'){
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid']),'credit2');
	$mymember=pdo_get('jy_jicai_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$member=array_merge($member,$mymember);
	$return['item']=$member;
	$jian_totype=$this->setting['jian_totype'];
	$credit_types=credit_types(true);
	$return['fee3title']=$jian_totype==1?$credit_types[1]:$credit_types[4];
	$return['fee1title']=$jian_totype==2?$credit_types[1]:$credit_types[2];
	$return['post']['pay_type']='wechat';
	set_html('title',$this->db_title.'转换');
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	$member=pdo_get('jy_jicai_member',array('mid'=>$_SESSION['uid']));
	$post=get_postdata();
	if(!$post['fee']){
		exi('请输入'.$this->db_title.'金额！','erroe');
	}
	if($member['baofee']<$post['fee']){
		exi('转换额度不能大于，当前'.$this->db_title.'额度！','erroe');
	}
	$fee=$post['fee'];
	$jian_tofee=$return['pluginset']['jian_tofee']?:50;
	$jian_tobi=$return['pluginset']['jian_tobi']?:50;
	$jian_tofee=$jian_tofee*$fee/100;
	$jian_tobi=$jian_tobi*$fee/100;
	if($jian_tobi>0){
		$jian_totype=$this->setting['jian_totype'];
		if($jian_totype==1){
			model('core/member')->member_credit($_SESSION['uid'],'credit1',$jian_tobi,true,'jy_jicai',$this->db_title.'转换');
		}else{
			model('core/member')->member_credit($_SESSION['uid'],'credit4',$jian_tobi,true,'jy_jicai',$this->db_title.'转换');
		}
	}
	if($jian_tofee>0){
		if($jian_totype==2){
			model('core/member')->member_credit($_SESSION['uid'],'credit1',$jian_tofee,true,'jy_jicai',$this->db_title.'转换');
		}else{
			model('core/member')->member_credit($_SESSION['uid'],'credit2',$jian_tofee,true,'jy_jicai',$this->db_title.'转换');
		}
	}
	pdo_update('jy_jicai_member',array('baofee -='=>$fee),array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$feelog['fee']=$fee;
	$this->model('model')->add_feelog($feelog,15);
	exi('转换成功！','success','goback');
}